package cmd

import (
	"gitee.com/xuender/oils/logs"
	"gitee.com/xuender/se"
	"github.com/spf13/cobra"
)

// nolint: gochecknoinits
func init() {
	fileCmd := &cobra.Command{
		Use:     "file",
		Aliases: []string{"f"},
		Short:   "显示索引文件详细信息",
		Long:    `显示索引文件详细信息，包括大小、修改时间、包含多所有词.`,
		Run: func(cmd *cobra.Command, args []string) {
			if len(args) == 0 {
				logs.Error("缺少参数，文件名或文件ID")

				return
			}

			app := se.InitApp(se.NewContext(cmd))
			defer app.Close()

			for _, f := range args {
				app.File(f)
			}
		},
	}

	rootCmd.AddCommand(fileCmd)
}
